package com.huangpeng.designmodel.singleton;

/**
 * @Author hp
 * @Title 懒汉式-线程安全
 * @Package
 * @Date 2022/1/19 10:04
 * @Description
 * @Version 1.0
 */
public class SlackerThreadSafety {
    public SlackerThreadSafety() {
    }
    private static SlackerThreadSafety slackerThreadSafety;
    public synchronized static SlackerThreadSafety getInstance(){
        if(slackerThreadSafety == null){
            slackerThreadSafety = new SlackerThreadSafety();
        }
        return slackerThreadSafety;
    }
    public static void main(String[] args){
        SlackerThreadSafety a1 = SlackerThreadSafety.getInstance();
        System.out.println("*********** " + a1.hashCode());
        SlackerThreadSafety a2 = SlackerThreadSafety.getInstance();
        System.out.println("*********** " + a2.hashCode());
    }
}
